import 'dart:io';

class VideoModel {
  final int id;
  final String description;
  final String url;
  final int collectCount;
  final int likeCount;
  final int commentCount;
  final String coverUrl; // 视频封面图片路径，可能是assets路径或文件路径

  VideoModel({
    required this.id,
    required this.description,
    required this.url,
    required this.collectCount,
    required this.likeCount,
    required this.commentCount,
    required this.coverUrl,
  });

  // 判断封面是否为本地文件路径
  bool get isCoverFile => coverUrl.startsWith('/');

  // 从JSON转换为对象
  factory VideoModel.fromJson(Map<String, dynamic> json) {
    return VideoModel(
      id: json['id'] as int,
      description: json['description'] as String,
      url: json['url'] as String,
      collectCount: json['collectCount'] as int,
      likeCount: json['likeCount'] as int,
      commentCount: json['commentCount'] as int,
      coverUrl: json['coverUrl'] as String,
    );
  }

  // 转换为JSON
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'description': description,
      'url': url,
      'collectCount': collectCount,
      'likeCount': likeCount,
      'commentCount': commentCount,
      'coverUrl': coverUrl,
    };
  }
}
